{extend name="public:layout" /}
{block name="title"}添加线索{/block}
{block name="head"}{/block}
{block name="body"}
<div class="app-form2">
    <form class="am-form app-form-line" id="leads" action="{:url('home/Leads/add')}" method="post">
        <fieldset>
            <div class="am-form-group">
                <label for="mobile" class="tit">手机号码</label>
                <input type="tel" class="input-text" datatype="*" nullmsg="请填写联系方式" id="mobile" name="mobile" placeholder="请输入客户联系方式">
                <a href="javascript:;" onclick="getInfo()"  class="action-link">
                    验重
                </a>
            </div>
            <div class="am-form-group">
                <label for="name" class="tit">客户名称</label>
                <input type="text" class="input-text" id="name" name="name" datatype="*" nullmsg="请填写客户名称" placeholder="请输入客户名称">
            </div>
            <div class="am-form-group checkbox-box">
                <label class="tit">性别</label>
                <label class="am-radio-inline radio">
                    <input type="radio"  datatype="*" nullmsg="请选择性别" value="先生" name="sex"> 先生
                </label>
                <label class="am-radio-inline radio">
                    <input type="radio" datatype="*" value="女士" name="sex"> 女士
                </label>
                <label class="am-radio-inline radio">
                    <input type="radio" datatype="*" value="未知" name="sex"> 未知
                </label>
            </div>
            <div class="am-form-group">
                <label for="doc-select-1" class="tit">线索来源</label>
                <select id="doc-select-1" class="select" datatype="*" nullmsg="请选择线索来源" name="source">
                    <option value="进店客户">进店客户</option>
                    <option value="老客户介绍">老客户介绍</option>
                    <option value="户外广告">户外广告</option>
                    <option value="搜索引擎">搜索引擎</option>
                    <option value="其他">其他</option>
                </select>
                <span class="am-form-caret"></span>
            </div>
            <div class="am-form-group">
                <label for="remark" class="tit">备注信息</label>
                <textarea class="textarea-text" name="remark" rows="5" id="remark" placeholder="请输入备注信息"></textarea>
            </div>
            <div class="submit-box f-hidden">
                <button type="submit" onclick="ajaxSubForm(this)"  class="am-btn am-btn-block am-btn-primary btnSub">添加线索</button>
            </div>
        </fieldset>
    </form>
</div>
{/block}
{block name="script"}
<script>
    dd.ready(function () {
        dd.biz.navigation.setMenu({
            backgroundColor : "#ADD8E6",
            textColor : "#ADD8E611",
            items : [
                {
                    "id":"1",//字符串
                    "iconId":"add",//字符串，图标命名
                    "text":"保存线索",
                    "url": "http://static.dingtalk.com/media/lALPBbCc1S7Gx91AQA_64_64.png"
                },
                {
                    "id":"2",
                    "iconId":"calendar",
                    "text":"线索列表"
                },
                {
                    "id":"3",
                    "iconId":"calendar",
                    "text":"主页"
                },
                {
                    "id":"4",
                    "iconId":"time",
                    "text":"刷新",
                },
            ],
            onSuccess: function(data) {
                if(data.id==1){
                    /*跟进信息*/
                    $('.btnSub').click();
                }else if(data.id==2){
                    /*线索列表*/
                    location.href="{:url('home/Index/index',['folder'=>'leads','file'=>'list'])}"+'&leads_status=1';
                }else if(data.id==3){
                    /*返回主页*/
                    location.href="{:url('home/Index/index',['folder'=>'index','file'=>'index'])}";
                }
                else if(data.id==4){
                    /*刷新页面*/
                    location.reload();
                };
            },
            onFail: function(err) {
            }
        });
    })
    /*验重*/
    function getInfo() {
        var mobile=$('#mobile').val();
        if(mobile!=''){
            $.post("{:url('home/Leads/getOneInfo')}",{mobile:mobile},function (res) {
                console.log(res);
               if(res.status==2){
                   layerMsg('没有线索信息，请继续添加');
               }else{
                   dd.ready(function () {
                       dd.device.notification.alert({
                           message: "已有线索信息，请跟进维护",
                           title: "提示",//可传空
                           buttonName: "查看线索",
                           onSuccess : function() {
                               location.href="{:url('home/Index/index',['folder'=>'leads','file'=>'info'])}"+'&leads_id='+res.data.leads_id;
                           },
                           onFail : function(err) {}
                       });
                   })
               }
            })
        }
    }
    $('#mobile').blur(function () {
        getInfo();
    })
</script>
{/block}